home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
398
/
398.xpi
/
chrome
/
forecastfox.jar
/
content
/
options
/
options.js
< prev
next >
Wrap
Text File
|
2010-02-04
|
29KB
|
882 lines
/*------------------------------------------------------------------------------
Copyright (c) 2008 Ensolis, LLC. All Rights Reserved.
----------------------------------------------------------------------------*/
var gOptions = null;
function optionsLoad()
{
gOptions = new OptionsModule();
gOptions.start();
}
function optionsUnload()
{
gOptions.stop();
gOptions = null;
}
function OptionsModule()
{
this.wrappedJSObject = this;
return this;
}
//XXX simplify code
OptionsModule.prototype = {
_dskSvc: null,
_prfSvc: null,
_icnSvc: null,
_migSvc: null,
_max: null,
_errors: null,
start: function OptionsModule_start()
{
//get the services
var mgrSvc = Cc["@ensolis.com/forecastfox/manager-service;1"].
getService(Ci.ffIManagerService);
this._dskSvc = mgrSvc.disk;
this._prfSvc = mgrSvc.profiles;
this._icnSvc = mgrSvc.icons;
this._migSvc = mgrSvc.migrator;
//setup the error array
this._errors = [];
//stop rotating profiles
this._prfSvc.endRotating();
//add observers
var obs = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
obs.addObserver(this, "forecastfox-profiles", false);
obs.addObserver(this, "forecastfox-icons", false);
//setup the display for the prefs
this.populateProfiles();
this.populateOptions();
this.populateIcons(true);
//enable-disable slider options
if (!checkAlertService()) {
document.getElementById("cc-slider").setAttribute("hidden", true);
document.getElementById("swa-slider").setAttribute("hidden", true);
}
//set the validate labels
this.populateValidLabels();
//select general page
var pages = document.getElementById("ff-list-pages");
pages.selectedItem = pages.childNodes[0];
},
stop: function OptionsModule_stop()
{
//start rotating profiles
this._prfSvc.startRotating();
//remove observers
try {
var obs = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
obs.removeObserver(this, "forecastfox-profiles");
obs.removeObserver(this, "forecastfox-icons");
obs = null;
} catch(e) {}
//release references
this._dskSvc = null;
this._prfSvc = null;
this._icnSvc = null;
this._migSvc = null;
this._max = null;
this._errors = null;
},
checkLocid: function OptionsModule_checkLocid()
{
if (getPref("general.locid") == "00000") {
// switch to the first page
var list = document.getElementById("ff-list-pages");
list.selectedItem = list.childNodes[0];
this.switchPage(list);
// then highlight the location id
var locid = document.getElementById("ff-text-code");
locid.focus();
locid.select();
}
},
switchPage: function OptionsModule_switchPage(aList)
{
var deck = document.getElementById("ff-deck-pages");
var page = aList.selectedIndex;
deck.selectedIndex = page;
},
populateProfiles: function OptionsModule_populateProfiles()
{
var list = document.getElementById("ff-list-profs");
var popup = document.getElementById("ff-popup-profs");
var id = this._prfSvc.current.ID;
var items = this._prfSvc.getItems({});
var item;
//remove old profiles
while (popup.hasChildNodes())
popup.removeChild(popup.lastChild);
//append new profiles
for (var x=0; x<items.length; x++) {
item = document.createElement("menuitem");
item.setAttribute("id", items[x].ID);
item.setAttribute("label", items[x].name);
item.setAttribute("value", items[x].ID);
item.setAttribute("type", "prof");
popup.appendChild(item);
if (items[x].ID == id)
list.selectedItem = item;
}
// if the current profile isn't around, select the first
// one in the list, and switch profiles to it.
if (list.selectedItem == null) {
list.selectedItem = popup.firstChild;
this._prfSvc.current = this._prfSvc.getItem(list.selectedItem.getAttribute("value"));
}
},
populateIcons: function OptionsModule_populateIcons(aRebuild)
{
var list = document.getElementById("ff-list-icons");
var id = this._icnSvc.current.ID;
var icons = this._icnSvc.getItems({});
//save current
var save = null;
if (list.selectedIndex >= 0)
save = list.selectedItem.value;
else
save = id;
//clear list
while (list.hasChildNodes() && aRebuild)
list.removeChild(list.lastChild);
//populate list
for (var x = 0; x < icons.length; x++) {
var item = aRebuild ? list.appendItem(icons[x].name, icons[x].ID) : list.getItemAtIndex(x);
//set selection
if (icons[x].ID == save) {
//XXX work around for bug 250123 (https://bugzilla.mozilla.org/show_bug.cgi?id=250123)
list.ensureElementIsVisible(item);
list.selectedItem = item;
}
//set current
if (icons[x].ID == id)
item.setAttribute("icon", "true");
else
item.removeAttribute("icon");
}
//set selected if not already
item = list.childNodes[0];
if (list.selectedIndex < 0) {
list.selectedItem = item;
}
//do select function
this.iconSelect();
},
populateOptions: function OptionsModule_populateOptions()
{
//general
this.setElement("ff-text-code", "general.locid", null);
this.setElement("ff-group-units", "units.current", "units");
this.populateBars();
this.populatePositions();
//swa panel
this.setElement("ff-chk-swa-panel", "swa.panel.enabled", null);
this.setElement("ff-list-swa-panel-display", "swa.panel.display", "ff-popup-swa-panel-display");
//swa tooltip
this.setElement("ff-chk-swa-tooltip", "swa.tooltip.enabled", null);
this.setElement("ff-list-swa-tooltip-display", "swa.tooltip.display", "ff-popup-swa-tooltip-display");
//swa slider
this.setElement("ff-chk-swa-slider", "swa.slider.enabled", null);
this.setElement("ff-list-swa-slider-display", "swa.slider.display", "ff-popup-swa-slider-display");
this.setElement("ff-text-swa-slider", "swa.slider.freq", null);
//radar panel
this.setElement("ff-chk-radar-panel", "radar.panel.enabled", null);
this.setElement("ff-list-radar-panel-display", "radar.panel.display", "ff-popup-radar-panel-display");
//radar tooltip
this.setElement("ff-chk-radar-tooltip", "radar.tooltip.enabled", null);
this.setElement("ff-list-radar-tooltip-display", "radar.tooltip.display", "ff-popup-radar-tooltip-display");
//hourly panel
this.setElement("ff-chk-hbh-panel", "hbh.panel.enabled", null);
//5 day panel
this.setElement("ff-chk-fiveday-panel", "fiveday.panel.enabled", null);
//current panel
this.setElement("ff-chk-cc-panel", "cc.panel.enabled", null);
this.setElement("ff-list-cc-panel-display", "cc.panel.display", "ff-popup-cc-panel-display");
//current tooltip
this.setElement("ff-chk-cc-tooltip", "cc.tooltip.enabled", null);
this.setElement("ff-list-cc-tooltip-display", "cc.tooltip.display", "ff-popup-cc-tooltip-display");
//current slider
this.setElement("ff-chk-cc-slider", "cc.slider.enabled", null);
this.setElement("ff-list-cc-slider-display", "cc.slider.display", "ff-popup-cc-slider-display");
this.setElement("ff-text-cc-slider", "cc.slider.freq", null);
//today's panel
this.setElement("ff-chk-dayt-panel", "dayt.panel.enabled", null);
this.setElement("ff-list-dayt-panel-display", "dayt.panel.display", "ff-popup-dayt-panel-display");
this.setElement("ff-list-dayt-panel-mode", "dayt.panel.mode", "ff-popup-dayt-panel-mode");
//today's tooltip
this.setElement("ff-chk-dayt-tooltip", "dayt.tooltip.enabled", null);
this.setElement("ff-list-dayt-tooltip-display", "dayt.tooltip.display", "ff-popup-dayt-tooltip-display");
//today's switch
this.setElement("ff-list-dayt-switch", "dayt.panel.switch", "ff-popup-dayt-switch");
//extended panel
this.setElement("ff-text-dayf-days", "dayf.panel.days", null);
this.setElement("ff-chk-dayf-panel", "dayf.panel.enabled", null);
this.setElement("ff-list-dayf-panel-display", "dayf.panel.display", "ff-popup-dayf-panel-display");
this.setElement("ff-list-dayf-panel-mode", "dayf.panel.mode", "ff-popup-dayf-panel-mode");
//extended tooltip
this.setElement("ff-chk-dayf-tooltip", "dayf.tooltip.enabled", null);
this.setElement("ff-list-dayf-tooltip-display", "dayf.tooltip.display", "ff-popup-dayf-tooltip-display");
//profiles
this.setElement("ff-chk-profs-rotate", "profile.switch.enabled", null);
this.setElement("ff-text-profs-rotate", "profile.switch.delay", null);
//links
this.setElement("ff-list-links-panel", "links.panel", "ff-popup-links-panel");
this.setElement("ff-list-links-alert", "links.alert", "ff-popup-links-alert");
this.setElement("ff-list-links-context", "links.context", "ff-popup-links-context");
this.setElement("ff-list-links-dialog", "links.dialog", "ff-popup-links-dialog");
this.checkLocid();
},
populateBars: function OptionsModule_populateBars()
{
// Creates the menuitems for the toolbar selector.
var win = getMainWindow();
var doc = win.document;
var toolbars = doc.getElementsByTagName("toolbar");
var statusbars = doc.getElementsByTagName("statusbar");
var menubars = doc.getElementsByTagName("menubar");
var popup = document.getElementById("ff-popup-bars");
var x, bar, item, val, list;
// first remove the toolbars already there...
while (popup.hasChildNodes())
popup.removeChild(popup.firstChild);
toolbars = concat(toolbars, statusbars);
toolbars = concat(toolbars, menubars);
for (x=0; x<toolbars.length; x++) {
bar = toolbars[x];
//do not include find toolbar
if (bar.getAttribute("id") == "FindToolbar")
continue;
item = document.createElement("menuitem");
item.setAttribute("id", bar.getAttribute("id"));
item.value = bar.getAttribute("id");
if (bar.hasAttribute("toolbarname"))
item.setAttribute("label", bar.getAttribute("toolbarname"));
else
item.setAttribute("label", bar.getAttribute("id"));
popup.appendChild(item);
}
this.setElement("ff-list-bars", "general.bar", "ff-popup-bars");
},
populatePositions: function OptionsModule_populatePositions()
{
if (!document.getElementById("ff-list-bars").selectedItem) {
setPref("general.bar", "status-bar");
setPref("general.position", -1);
this.setElement("ff-list-bars", "general.bar", "ff-popup-bars");
}
var barid = document.getElementById("ff-list-bars").selectedItem.getAttribute("id");
var win = getMainWindow();
var doc = win.document;
var bar = doc.getElementById(barid);
if (!bar)
this._max = 0;
else {
var len = bar.childNodes.length;
//don't include ourself in count
if (doc.getElementById("ff-box") && doc.getElementById("ff-box").parentNode == bar)
len--;
this._max = len;
}
var val = getPref("general.position");
var val2 = getPref("general.bar");
var text = document.getElementById("ff-text-position");
var radio = document.getElementsByAttribute("group", "position");
var group = document.getElementById("ff-group-position");
var x, el;
//set max value
text.value = this._max;
//mark always last
if (val == -1) {
for (x=0; x < radio.length; x++) {
if (parseInt(radio[x].value) == val) {
group.selectedItem = radio[x];
break;
}
}
}
//mark specific position
else {
for (x=0; x < radio.length; x++) {
if (parseInt(radio[x].value) != -1) {
group.selectedItem = radio[x];
break;
}
}
if (barid != val2) {
text.value = this._max;
} else {
if (val < 0)
text.value = this._max;
else if (val > this._max)
text.value = 0;
else
text.value = val;
}
}
// update the error label
el = document.getElementById("ff-text-position-valid");
el.setAttribute("value", "0-"+this._max);
//revalidate position
var comp = this;
window.setTimeout(function() { comp.validate(); }, 10);
},
populateValidLabels: function OptionsModule_populateValidLabels()
{
var el;
el = document.getElementById("ff-text-position-valid");
el.setAttribute("value", "0-"+this._max);
el = document.getElementById("ff-text-swa-slider-valid");
el.setAttribute("value", "0-16");
el = document.getElementById("ff-text-cc-slider-valid");
el.setAttribute("value", "0-16");
el = document.getElementById("ff-text-dayf-days-valid");
el.setAttribute("value", "0-8");
el = document.getElementById("ff-text-profs-rotate-valid");
el.setAttribute("value", "0-480");
},
setElement: function OptionsModule_setElement(aName, aPref, aGroup)
{
var x, els;
var el = document.getElementById(aName);
var val = getPref(aPref);
switch (el.localName) {
case "checkbox":
el.checked = val;
break;
case "textbox":
el.value = this._decodeValue(val);
break;
case "menulist":
els = document.getElementById(aGroup).childNodes;
for (x=0; x < els.length; x++) {
if (((typeof val == "number") ? parseInt(els[x].value) : els[x].value) == val) {
el.selectedItem = els[x];
break;
}
}
break;
case "radiogroup":
els = document.getElementsByAttribute("group", aGroup);
for (x=0; x < els.length; x++) {
if (((typeof val == "number") ? parseInt(els[x].value) : els[x].value) == val) {
el.selectedItem = els[x];
break;
}
}
break;
}
},
setOption: function OptionsModule_setOption(aName, aPref, aType)
{
var el = document.getElementById(aName);
var val;
switch (el.localName) {
case "checkbox":
val = el.checked;
break;
case "textbox":
val = (aType == "Int") ? parseInt(el.value) : this._encodeValue(el.value);
break;
case "menulist":
case "radiogroup":
val = (aType == "Int") ? parseInt(el.selectedItem.value) : this._encodeValue(el.selectedItem.value);
break;
}
setPref(aPref, val);
},
selectProfile: function OptionsModule_selectProfile(aList)
{
var id = aList.selectedItem.getAttribute("value");
var popup = document.getElementById("ff-popup-profs");
popup.hidePopup();
this._prfSvc.current = this._prfSvc.getItem(id);
},
validate: function OptionsModule_validate()
{
//remove error indicators
for (var i=0; i < this._errors.length; i++)
this._errors[i].removeAttribute("error");
this._errors = [];
//check location code
var el = document.getElementById("ff-text-code");
if ((el.value == "") || (el.value == "00000"))
return this.markError(el, 0);
//check position
el = document.getElementById("ff-text-position");
var el2 = document.getElementById("ff-text-position-valid");
if (isNaN(parseInt(el.value)) || el.value < 0 || el.value > this._max)
return this.markError(el, 0, el2);
//check swa slider
el = document.getElementById("ff-text-swa-slider");
el2 = document.getElementById("ff-text-swa-slider-valid");
if (isNaN(parseInt(el.value)) || el.value < 0 || el.value > 16)
return this.markError(el, 1, el2);
//check cc slider
el = document.getElementById("ff-text-cc-slider");
el2 = document.getElementById("ff-text-cc-slider-valid");
if (isNaN(parseInt(el.value)) || el.value < 0 || el.value > 16)
return this.markError(el, 3, el2);
//check extended days
el = document.getElementById("ff-text-dayf-days");
el2 = document.getElementById("ff-text-dayf-days-valid");
if (isNaN(parseInt(el.value)) || el.value < 0 || el.value > 8)
return this.markError(el, 5, el2);
//check profiles rotat
el = document.getElementById("ff-text-profs-rotate");
el2 = document.getElementById("ff-text-profs-rotate-valid");
if (isNaN(parseInt(el.value)) || el.value < 0 || el.value > 480)
return this.markError(el, 6, el2);
//return valid
return true;
},
markError: function OptionsModule_markError(aEl, aIndex, aE2)
{
// aE2 is optional: xul object containing a description that will be shown
//get page list
var list = document.getElementById("ff-list-pages");
//mark element
aEl.setAttribute("error", "true");
if (aE2)
aE2.setAttribute("error", "valid");
// set to valid so css rules don't interfere
//switch to page
list.selectedItem = list.childNodes[aIndex];
this.switchPage(list);
//add to error array
this._errors.push(aEl);
if (aE2)
this._errors.push(aE2);
return false;
},
accept: function OptionsModule_accept(aClose)
{
if (!this.validate())
return;
this.updateOptions();
//make sure we save profile
this._prfSvc.setItem(this._prfSvc.current);
if (aClose)
window.close();
else
document.getElementById("apply").setAttribute("disabled", "true");
},
updateOptions: function OptionsModule_updateOptions()
{
//general
this.setOption("ff-text-code", "general.locid", "Char");
this.setOption("ff-group-units", "units.current", "Complex");
this.setOption("ff-list-bars", "general.bar", "Char");
var position = document.getElementById("ff-group-position");
if (parseInt(position.selectedItem.value) == -1)
setPref("general.position", -1);
else
this.setOption("ff-text-position", "general.position", "Int");
//swa panel
this.setOption("ff-chk-swa-panel", "swa.panel.enabled", "Bool");
this.setOption("ff-list-swa-panel-display", "swa.panel.display", "Int");
//swa tooltip
this.setOption("ff-chk-swa-tooltip", "swa.tooltip.enabled", "Bool");
this.setOption("ff-list-swa-tooltip-display", "swa.tooltip.display", "Int");
//swa slider
this.setOption("ff-chk-swa-slider", "swa.slider.enabled", "Bool");
this.setOption("ff-list-swa-slider-display", "swa.slider.display", "Int");
this.setOption("ff-text-swa-slider", "swa.slider.freq", "Int");
//radar panel
this.setOption("ff-chk-radar-panel", "radar.panel.enabled", "Bool");
this.setOption("ff-list-radar-panel-display", "radar.panel.display", "Int");
//radar tooltip
this.setOption("ff-chk-radar-tooltip", "radar.tooltip.enabled", "Bool");
this.setOption("ff-list-radar-tooltip-display", "radar.tooltip.display", "Int");
//hourly panel
this.setOption("ff-chk-hbh-panel", "hbh.panel.enabled", "Bool");
//5 day panel
this.setOption("ff-chk-fiveday-panel", "fiveday.panel.enabled", "Bool");
//current conditions panel
this.setOption("ff-chk-cc-panel", "cc.panel.enabled", "Bool");
this.setOption("ff-list-cc-panel-display", "cc.panel.display", "Int");
//current conditions tooltip
this.setOption("ff-chk-cc-tooltip", "cc.tooltip.enabled", "Bool");
this.setOption("ff-list-cc-tooltip-display", "cc.tooltip.display", "Int");
//current conditions slider
this.setOption("ff-chk-cc-slider", "cc.slider.enabled", "Bool");
this.setOption("ff-list-cc-slider-display", "cc.slider.display", "Int");
this.setOption("ff-text-cc-slider", "cc.slider.freq", "Int");
//today's panel
this.setOption("ff-chk-dayt-panel", "dayt.panel.enabled", "Bool");
this.setOption("ff-list-dayt-panel-display", "dayt.panel.display", "Int");
this.setOption("ff-list-dayt-panel-mode", "dayt.panel.mode", "Int");
//today's tooltip
this.setOption("ff-chk-dayt-tooltip", "dayt.tooltip.enabled", "Bool");
this.setOption("ff-list-dayt-tooltip-display", "dayt.tooltip.display", "Int");
//today's switch
this.setOption("ff-list-dayt-switch", "dayt.panel.switch", "Int");
//extended panel
this.setOption("ff-text-dayf-days", "dayf.panel.days", "Int");
this.setOption("ff-chk-dayf-panel", "dayf.panel.enabled", "Bool");
this.setOption("ff-list-dayf-panel-display", "dayf.panel.display", "Int");
this.setOption("ff-list-dayf-panel-mode", "dayf.panel.mode", "Int");
//extended tooltip
this.setOption("ff-chk-dayf-tooltip", "dayf.tooltip.enabled", "Bool");
this.setOption("ff-list-dayf-tooltip-display", "dayf.tooltip.display", "Int");
//profiles
this.setOption("ff-chk-profs-rotate", "profile.switch.enabled", "Bool");
this.setOption("ff-text-profs-rotate", "profile.switch.delay", "Int");
//links
this.setOption("ff-list-links-panel", "links.panel", "Char");
this.setOption("ff-list-links-alert", "links.alert", "Char");
this.setOption("ff-list-links-context", "links.context", "Char");
this.setOption("ff-list-links-dialog", "links.dialog", "Char");
},
_encodeValue: function OptionsModule__encodeValue(aValue)
{
// only encode the strings
if (typeof aValue != "string")
return aValue;
// prepare the quotes so that we can use eval
return trim(aValue.replace(/"/g,"\\\"").replace(/'/g,"\\\'"));
},
_decodeValue: function OptionsModule__decodeValue(aValue)
{
// only encode the strings
if (typeof aValue != "string")
return aValue;
// unescape the quotes
return trim(aValue.replace(/\\"/g,"\"").replace(/\\'/g,"\'"));
},
importDOM: function OptionsModule_importDOM()
{
var bundle = document.getElementById("ff-bundle-options");
var success = this._migSvc.importDOM(window);
var prompter = getPrompter(window);
if (!success) {
var err = this._migSvc.lastError;
if (err.severity < SEVERITY_ERROR)
return;
prompter.alert(err.name, err.message);
return;
} else
prompter.alert(bundle.getString("ff.import.title"),
bundle.getString("ff.import.success"));
this.populateProfiles();
this.populateOptions();
},
exportDOM: function OptionsModule_exportDOM()
{
var bundle = document.getElementById("ff-bundle-options");
var success = this._migSvc.exportDOM(window);
var prompter = getPrompter(window);
if (!success) {
var err = this._migSvc.lastError;
if (err.severity < SEVERITY_ERROR)
return;
prompter.alert(err.name, err.message);
return;
} else
prompter.alert(bundle.getString("ff.export.title"),
bundle.getString("ff.export.success"));
},
iconSelect: function OptionsModule_iconSelect()
{
var uninstall = document.getElementById("ff-btn-icons-uninstall");
var select = document.getElementById("ff-btn-icons-select");
var preview = document.getElementById("ff-preview-image");
var author = document.getElementById("ff-link-icon-author");
var version = document.getElementById("ff-lbl-icon-version");
//remove values
uninstall.setAttribute("disabled", "true");
select.setAttribute("disabled", "true");
preview.src = "chrome://forecastfox/skin/images/preview.png";
version.value = "";
author.label = "";
author.removeAttribute("tooltiptext");
author.href = "";
var list = document.getElementById("ff-list-icons");
if (list.selectedIndex < 0)
return;
//fill out metadata
var pack = this._icnSvc.getItem(list.selectedItem.value);
var url = pack.getPreviewURL();
if (url != "")
preview.src = url;
version.value = pack.getProperty("version");
author.label = pack.getProperty("author");
author.setAttribute("tooltiptext", pack.getProperty("website"));
author.href = pack.getProperty("website");
//enable uninstall
var id = this._icnSvc.current.ID;
if (pack.ID != "default")
uninstall.removeAttribute("disabled");
//enable select
if (pack.ID != id)
select.removeAttribute("disabled");
},
iconInstall: function OptionsModule_iconInstall()
{
var prompter = getPrompter(window);
var bundle = document.getElementById("ff-bundle-options");
//get file
var picker = Cc["@mozilla.org/filepicker;1"].
createInstance(Ci.nsIFilePicker);
picker.appendFilter(bundle.getString("ff.options.icons.filter"), "*.jar");
picker.defaultExtension = ".jar";
picker.init(window, bundle.getString("ff.options.icons.picker"), picker.modeOpen);
// get the file and its contents
var res = picker.show();
if (res == picker.returnCancel)
return;
//perform install
var rv = this._icnSvc.setItem(picker.file);
if (!rv)
prompter.alert(bundle.getString("ff.options.icons.picker"), bundle.getString("ff.icons.failed"));
else
prompter.alert(bundle.getString("ff.options.icons.picker"), bundle.getString("ff.icons.success"));
},
iconUninstall: function OptionsModule_iconUninstall()
{
var prompter = getPrompter(window);
var bundle = document.getElementById("ff-bundle-options");
var list = document.getElementById("ff-list-icons");
var name = list.selectedItem.label;
var current = this._icnSvc.current.id;
var id = list.selectedItem.value;
var rv = prompter.confirm(bundle.getString("ff.options.icons.picker"), bundle.getFormattedString("ff.icons.uninstall", [name]));
if (!rv)
return;
//select default pack
if (id == current)
this._icnSvc.current = getItem("default");
//perform uninstall
try {
rv = this._icnSvc.deleteItem(id);
} catch(e) {
this._dskSvc.log("Icon pack uninstall error.", e, null);
}
},
iconSet: function OptionsModule_iconSet()
{
//remove attribute on list items
var list = document.getElementById("ff-list-icons");
for (var x=0; x<list.childNodes.length; x++)
list.childNodes[x].removeAttribute("icon");
//set icon
this._icnSvc.current = this._icnSvc.getItem(list.selectedItem.value);
},
observe: function OptionsModule_observe(aSubject, aTopic, aData)
{
switch (aTopic) {
//profile notification
case "forecastfox-profiles":
//ignore while loading or batch
if (this._prfSvc.isLoading || this._prfSvc.isBatch)
return;
//ignore startBatch notification
if (aData == "startBatch")
return;
//current changed, profile added, profile deleted, or end batch
this.populateProfiles();
this.populateOptions();
this.populateIcons(false);
break;
//icon notification
case "forecastfox-icons":
//ignore while loading or batch
if (this._icnSvc.isLoading || this._icnSvc.isBatch)
return;
switch (aData) {
//current pack changed
case "current":
this.populateIcons(false);
break;
//icon pack added, deleted, or batch ended
case "setItem":
case "deleteItem":
case "endBatch":
this.populateIcons(true);
break;
}
break;
}
}
};
function updateButtons(aEvent)
{
// don't enable the apply button for button presses
if (aEvent) {
if ((aEvent.originalTarget.localName == "button") ||
(aEvent.originalTarget.localName == "fflink") ||
(aEvent.originalTarget.getAttribute("type") == "prof"))
return;
}
document.getElementById("apply").removeAttribute("disabled");
}
function concat(c1, c2)
{
// Concats too collections into an array.
var c3 = new Array(c1.length + c2.length);
var x,y = 0;
for (x = 0; x < c1.length; x++)
c3[y++] = c1[x];
for (x = 0; x < c2.length; x++)
c3[y++] = c2[x];
return c3;
}
// trims trailing and leading white space
function trim(aString) {
aString = aString.replace(/^\s+/g, "");
return aString.replace(/\s+$/g, "");
}